using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.Reflection;
using System;

public class ListGUILayer 
{
     static MethodInfo methodType;
     
    public static void GUIClass<T>(string label,List<T> list) where T : UnityEngine.Object
    {
        List<T> temp = new List<T>();
        int count = 0;
        EditorGUILayout.LabelField(label, EditorStyles.boldLabel);
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(10);
        EditorGUILayout.BeginVertical();

        if (list == null||list.Count <= 0)
        {
            EditorGUILayout.LabelField("[Empty]");
        }
        foreach (var item in list)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField($"Element {count}",GUILayout.Width(100));
            EditorGUILayout.ObjectField(item, typeof(T), true);
            EditorGUILayout.EndHorizontal();
            count++;
        }
        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();
    }

    

    public static void GUIValue<T>(string label, List<T> list)
    {
        List<T> temp = new List<T>();
        int count = 0;
        EditorGUILayout.LabelField(label, EditorStyles.boldLabel);
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(10);
        EditorGUILayout.BeginVertical();

        if (list == null || list.Count <= 0)
        {
            EditorGUILayout.LabelField("[Empty]");
        }
        foreach (var item in list)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField($"Element {count}", GUILayout.Width(100));

            if (typeof(T).IsValueType)
            {
                EditorGUILayout.LabelField(item.ToString());
            }
            EditorGUILayout.BeginVertical();
            count++;
        }
        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();
    }


    public static void GUIText(string label,ref string text)
    {
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(10);
        EditorGUILayout.LabelField(label, EditorStyles.boldLabel,GUILayout.Width(150));
        text = EditorGUILayout.TextField(text);
        EditorGUILayout.EndHorizontal();
    }


}
